﻿using MaterialSkin;
using MaterialSkin.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PolyCrypt
{
    public partial class CryptForm : MaterialForm
    {
        private MaterialSkinManager materialSkinManager;
        private string default_title;

        public CryptForm()
        {            
            InitializeComponent();
            default_title = this.Text;
            this.initPages();
            initSkin();
        }
        private void initPages()
        {
            var crypts = CryptHelper.getCryptProviders();
            foreach (var crypt in crypts)
            {
                TabPage page = new TabPage
                {
                    Text = crypt.Name,
                    ImageKey = crypt.ImageKey
                };
                
                page.Controls.Add(crypt.Control);
                crypt.Control.Dock = DockStyle.Fill;
                tabCrypts.Controls.Add(page);

            }
            this.tabCrypts_SelectedIndexChanged(null, null);
        }
        private void initSkin()
        {
            // Initialize MaterialSkinManager
            materialSkinManager = MaterialSkinManager.Instance;

            // Set this to false to disable backcolor enforcing on non-materialSkin components
            // This HAS to be set before the AddFormToManage()
            materialSkinManager.EnforceBackcolorOnAllComponents = true;

            // MaterialSkinManager properties
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE);

        }

        private void tabCrypts_SelectedIndexChanged(object sender, EventArgs e)
        {
            var index = tabCrypts.SelectedIndex;
            if (index < 0)
            {
                this.Text = default_title;
                return;
            }
            var tab = tabCrypts.SelectedTab;
            this.Text = default_title + " -- " + tab.Text;
        }
    }
}
